/*
 * @Author: xiaosihan
 * @Date: 2021-03-30 22:57:45
 * @Last Modified by: xiaosihan
 * @Last Modified time: 2021-05-19 01:49:55
 */

import * as THREE from "three";

export default function SkinnedMesh_mixin() {

    Object.assign(THREE.SkinnedMesh.prototype, {

        bind(skeleton: THREE.Skeleton, bindMatrix?: THREE.Matrix4): void {

            let anyThis = (this as unknown as THREE.SkinnedMesh);

            anyThis.skeleton = skeleton;

            if (bindMatrix === undefined) {

                // anyThis.updateMatrixWorld(true);
                anyThis.skeleton.calculateInverses();
                bindMatrix = anyThis.matrixWorld;
            }

            anyThis.bindMatrix.copy(bindMatrix);
            anyThis.bindMatrixInverse.copy(bindMatrix).invert();
        }

    });
}